import { ConfigConst } from "./ConfigConst";
import { Log } from "../../../../com/gengine/debug/Log";
import { ConfigManager } from "../../../../com/gengine/resource/ConfigManager";
import { ClassTypesUtil } from "../../view/common/ClassTypesUtil";
//class ConfigBase2
    
    export  class ConfigBase2
    {
        constructor(arg1: string)
        {
            
            this.initConfig(arg1);
            return;
        }

        protected initConfig(arg1: string): void
        {
            var loc5=null;
            var loc6=null;
            var loc1=ConfigConst.map[arg1];
            if (loc1 == null || loc1 == "") 
            {
                Log.debug("在ConfigConst.map中找不到：" + arg1 + "的配置");
            }
            var loc2=flash.utils.getDefinitionByName(loc1) as Class;
            if (loc2 == null) 
            {
                Log.debug("找不到类名定义：" + loc1);
            }
            this._data = new Map<any, any> /* flash.utils.Dictionary */();
            var loc3;
            if ((loc3 = ConfigManager.instance.getJSONByFileName(arg1)) == null) 
            {
                Log.debug("ConfigFiles: 加载不到配置文件:" + arg1);
                return;
            }
            var loc4=0;
            var loc7=0;
            var loc8=loc3;
            for(loc5 of loc8) 
            {
                loc6 = new loc2();
                ClassTypesUtil.copyValue(loc6, loc5);
                var loc9;
                this._data[loc9 = loc4++] = loc6;
            }
            return;
        }

        /* internal  */cobine(): void
        {
            var loc1=null;
            return;
        }

        public get data(): Map<any, any> /* flash.utils.Dictionary */
        {
            return this._data;
        }

        public getConfigs(arg1: Array<any>, arg2: Array<any>, arg3: Map<any, any> /* flash.utils.Dictionary */=null): Array<any>
        {
            var loc3=null;
            var loc4=0;
            var loc5=null;
            var loc1=this._data;
            if (arg3 != null) 
            {
                loc1 = arg3;
            }
            var loc2=[];
            if (loc1 == null) 
            {
                return loc2;
            }
            if (arg1 == null || arg1.length == 0) 
            {
                return this.dicToArray(loc1);
            }
            if (arg1 == null || arg1.length == 0 || arg2 == null || arg2.length == 0) 
            {
                return this.dicToArray(loc1);
            }
            var loc6=0;
            var loc7=loc1;
            for(loc3 of loc7) 
            {
                loc4 = 0;
                while (loc4 < arg1.length) 
                {
                    loc5 = arg1[loc4] as string;
                    if (loc3[loc5] != arg2[loc4]) 
                    {
                        continue;
                    }
                    if (loc4 == (arg1.length - 1)) 
                    {
                        loc2.push(loc3);
                    }
                    ++loc4;
                }
            }
            return loc2;
        }

        /* internal  */dicToArray(arg1: Map<any, any> /* flash.utils.Dictionary */): Array<any>
        {
            var loc2=undefined;
            var loc1=[];
            if (arg1 == null) 
            {
                return loc1;
            }
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1.push(loc2);
            }
            return loc1;
        }

        protected /* var */_data: Map<any, any> /* flash.utils.Dictionary */;
    }
